package com.github.prontera.service;

import java.math.BigDecimal;
import java.time.OffsetDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.github.prontera.domain.ClientActivity;
import com.github.prontera.persistence.CrudMapper;

/**
 * 用户活动
 */
@Service
public class ClientActivityService extends CrudServiceImpl<ClientActivity>{
    
  	@Autowired
    public ClientActivityService(CrudMapper<ClientActivity> mapper) {
        super(mapper);
    }

  	@Transactional(propagation = Propagation.REQUIRED)
  	public int insert(Long activityId,Long clientId,BigDecimal payAmount) {
  		ClientActivity clientActivity=new ClientActivity();
  		clientActivity.setActivityId(activityId);
  		clientActivity.setClientId(clientId);
  		clientActivity.setPayAmount(payAmount);
  		clientActivity.setPayTime(OffsetDateTime.now());
  		return mapper.insert(clientActivity);
	}
  	
}
